/**
 * @file DotMode.cpp
 * @see DotMode
 * @see IRenderMode
 * @author M. Caputo
 * @date 2010-03-26
 */

#include <QtOpenGL>
#include "DotMode.h"

QString DotMode::name()
{
	return tr("Dot Mode");
}

void DotMode::setSettings()
{
	glEnable(GL_DEPTH_TEST);
	glPointSize(2.0);
}

void DotMode::unsetSettings()
{
	glPointSize(1.0);
	glDisable(GL_DEPTH_TEST);
}

void DotMode::draw(const IScene *scene, const QColor & defaultColor)
{
	glColor3f(
		defaultColor.redF(),
		defaultColor.greenF(),
		defaultColor.blueF()
	);
	
	glBegin( GL_POINTS );
	int cp = scene->polygonsCount();
	for(int i=0; i<cp; i++) {
		const CPolygon *poly = scene->polygon(i);
		int cv = poly->verticesCount();
		for(int j=0; j<cv; j++) {
			const CVertex *vert = poly->vertex(j);
			const float *data = vert->vertex();
			glVertex3fv(data);
		}
	}
	glEnd();
}
